<!--FORM UPDATE SO LUONG VAI-->
<form action="index.php?quanlybanhang&module=updatevai" method="post" enctype="multipart/form-data">
<fieldset>
<legend><h1>Update số lượng vải</h1></legend>
<?php
//--IN RA DU LIEU CHUA CHINH SUA
if (isset($_GET['update']))
{
    $vaiid = $_GET['vaiid'];
    $sql = mysql_query("SELECT * FROM vai WHERE vaiid = $vaiid");
    while ($row = mysql_fetch_array($sql))
    {
?> 
<table width="408" border="0">
  <tr>
    <td>Khối lượng</td>
    <td><input type="text" name="khoiluong" id="khoiluong" value="0" onfocus="tinhquydoi();" onkeyup="tinhquydoi();" /> kg</td>
  </tr>
  <tr>
    <td>Quy đổi</td>
    <td><input type="text" name="quydoi" id="tilequydoi" value="0" onfocus="tinhquydoi();" onkeyup="tinhquydoi();" /> áo/kg</td>
  </tr>
  <tr>
    <td>Số lượng áo </td>
    <td><input type="text" name="soluong" id="soluong" onfocus="this.blur();" class="locked" /> áo/kg</td>
  </tr>
    <td><input type="hidden" name="vaiid" value="<?php print "$row[vaiid]";  ?> " /></td>    
    <td><input class="button" type="submit" name="submit" value="Update" /></td>
  </tr>
</table>
</fieldset>
</form>
<?php }} ?>


<?php 
//--SUA SO LUONG
    if (isset($_POST['submit']))
    {
            //print_r ($_POST);
            $vaiid = $_POST['vaiid'];
            $soluong = $_POST['soluong'];            
            $sql = "update vai set soluong = '$soluong' where vaiid='$vaiid'";
            
            $result= mysql_query($sql);
            if ($result)
                {
                    print "<h2>Thành công!</h2><a href='index.php?module=vai'><h2>Quay lại</h2></a>";
                    print "<script> alert('Thành công');
                                    window.location='index.php?quanlybanhang&module=vai';</script>";                   
                }

                
    }
?>  